package com.zzty.txj.dao;

import com.zzty.txj.entity.DoDaily;
import com.zzty.txj.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface RecordMapper {
    @Select("select * from doDaily where userId=#{userId} and date=#{date}")
    public List<DoDaily> getDoDaily(DoDaily doDaily);

    @Select("select id from user where openId=#{openId}")
    public Integer getUserId(String openId);

    @Select("select name from daily where id=#{id}")
    public String getDailyName(Integer id);
    @Select("select * from doDaily ")
    public List<DoDaily> getDaily();
    @Select("SELECT * FROM doDaily where DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(date) and userId=#{id}")
    public List<DoDaily> getWeek(User user);
    @Select("SELECT * FROM doDaily WHERE PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(date,'%Y%m')) =1 and userId=#{id}")
    public List<DoDaily> getMonth(User user);

}
